package collections;

import java.util.ArrayList;

/**
 * @Author: DRevelation
 * @Date: 2022/4/7 11:08
 */
public class ApplesAndOrangesWithoutGenerics {

    @SuppressWarnings("unchecked")
    public static void main(String[] args) {
        ArrayList lists = new ArrayList();
        lists.add(new Apple());
        lists.add(new Orange());
        lists.add(new Apple());

        for (Object apple : lists) {
            ((Apple) apple).id();
        }
    }
}

class Apple {
    private static long counter;
    private final long id = counter++;

    public long id() {
        return id;
    }
}

class Orange {

}
